home *** CD-ROM | disk | FTP | other *** search
- DLSYM(3C) Last changed: 3-11-99
-
-
- NNAAMMEE
- ddllssyymm - Gets the address of a symbol in shared object
-
- SSYYNNOOPPSSIISS
- cccc [_o_p_t_i_o_n_s ...] _f_i_l_e ... --llcc [_l_i_b_r_a_r_y ...]
-
- ##iinncclluuddee <<ddllffccnn..hh>>
-
- vvooiidd **ddllssyymm((vvooiidd **_h_a_n_d_l_e,, ccoonnsstt cchhaarr **_n_a_m_e));;
-
- IIMMPPLLEEMMEENNTTAATTIIOONN
- IRIX systems
-
- DDEESSCCRRIIPPTTIIOONN
- ddllssyymm obtains the address of a symbol defined within a shared object
- previously opened by ddllooppeenn, ssggiiddllooppeenn__vveerrssiioonn, or ssggiiddllaadddd. It
- accepts the following arguments:
-
- _h_a_n_d_l_e The value returned by a call to ddllooppeenn(3C). ddllcclloossee(3C)
- must not have been used to close the corresponding shared
- object.
-
- _n_a_m_e The symbol's name as a character string. ddllssyymm searches
- for the named symbol in all shared objects loaded
- automatically as a result of loading the object referenced
- by _h_a_n_d_l_e. For more information, see ddllooppeenn(3C).
-
- The named object is searched and then the library list of
- the DSO opened on _h_a_n_d_l_e is searched (in a pre-order,
- breadth-first search of all listed DSOs). The first visible
- symbol with the requested name (weak or strong) is returned.
-
- For information on how names are generally resolved, as distinct from
- ddllssyymm resolution, and on symbol visibility see the NAMESPACE ISSUES
- section of the ddllooppeenn(3C) man page.
-
- For names on the handle returned by ddllooppeenn((((cchhaarr **))00,,_f_l_a_g_s)), the name
- resolution is in rrlldd(5)-list order according to the internal list
- maintained at run time by rrlldd(5). For other handles, name resolution
- is in breadth-first order based on following the library-list
- (liblist) of the DSO named in the ddllooppeenn((_n_a_m_e,,_f_l_a_g_s)) call. Normally,
- these searches result in the same sequence of DSOs being searched, but
- the former searches file aa..oouutt and all globally visble DSOs. The
- latter, however, searches only DSOs in the transitive closure of the
- library-list of the named DSO.
-
- RREETTUURRNN VVAALLUUEESS
- When casting the return type of ddllssyymm to be a function pointer, the C
- or C++ compiler might emit the following warning:
-
- warning(1048): cast between pointer-to-object and pointer-to-function
-
- While a cast from pointer-to-data to pointer-to-function is not
- necessarily portable to all systems, which is what the warning means,
- the cast and the resulting call perform correctly on any system that
- supports ddllssyymm. When getting function addresses, one could define a
- function such as the one in the following example and call it instead
- of ddllssyymm:
-
- int (*dlsymfunc(void *handle,char *name))();
- int (*dlsymfunc(void *handle,char *name))()
- {
- return (int (*)())dlsym(handle,name);
- }
-
- This would have the effect of moving the warning message to a single
- spot in the program (the ddllssyymmffuunncc definition) so that the rest of the
- code does not generate this warning.
-
- If _h_a_n_d_l_e does not refer to a valid object opened by ddllooppeenn(3C), or if
- the named symbol cannot be found within any of the objects associated
- with _h_a_n_d_l_e, ddllssyymm returns NNUULLLL. More detailed diagnostic information
- is available through ddlleerrrroorr(3C).
-
- EEXXAAMMPPLLEESS
- The following example shows how one can use ddllooppeenn(3C) and ddllssyymm to
- access either function or data objects. For simplicity, error
- checking has been omitted.
-
- void *handle;
- int i, *iptr;
- int (*fptr)(int);
-
- /* open the needed object */
- handle = dlopen("/usr/mydir/libx.so", RTLD_LAZY);
-
- /* find address of function and data objects */
- fptr = (int (*)(int))dlsym(handle, "some_function");
-
- iptr = (int *)dlsym(handle, "int_object");
-
- /* invoke function, passing value of integer as a parameter */
-
- i = (*fptr)(*iptr);
-
- SSEEEE AALLSSOO
- ddllcclloossee(3C), ddlleerrrroorr(3C), ddllooppeenn(3C), ssggiiddllaadddd(3C),
- ssggiiggeettddssoovveerrssiioonn(3C)
-
- This man page is available only online.
-